package com.hzjh.h5mall.model.login

import com.hzjh.base.ext.data.UserConfigs
import com.hzjh.base.ext.frame.JHBaseVM
import com.hzjh.base.http.toVersionParams
import com.hzjh.base.log.JHLogger
import com.hzjh.base.utils.other.ActivityStackManage
import com.hzjh.h5mall.http.MallApi

class LoginVM : JHBaseVM() {
    //登录
    fun reqEmailLogin(email:String,password:String) {
        val params = HashMap<Any, Any>()
        params["email"] = email
        params["password"] = password
        makeCall {
            onRequest {
                MallApi.create().reqEmailLogin(params.toVersionParams())
            }
            onSuccess {
                //注册成功 token
                UserConfigs.saveUserData(it)
                ActivityStackManage.toMainActivity()
                JHLogger.d(UserConfigs.getUserData().token?:"")
            }
        }
    }
}